package lunceneDemo;

import java.io.IOException;
import java.nio.file.FileSystems;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.QueryBuilder;

public class SerachFile {
	public static void main(String[] args) throws IOException {
//		Directory directory=FSDirectory.open(FileSystems.getDefault().getPath("D:\\TestLuncene\\index_6.5"));
//		Analyzer analyzer=new StandardAnalyzer();
//		IndexReader indexReader=DirectoryReader.open(directory);
//		IndexSearcher searcher=new IndexSearcher(indexReader);
//		
//		QueryBuilder builder=new QueryBuilder(analyzer);
//		Query query = builder.createPhraseQuery("filename", "2222");
//		
//		BooleanQuery.Builder bo=new BooleanQuery.Builder();
//		
//		
//		TopDocs search = searcher.search(query, 10);
//		System.out.println(search.totalHits);
//		ScoreDoc[] scoreDocs = search.scoreDocs;
//		for (ScoreDoc scoreDoc : scoreDocs) {
//			System.out.println(scoreDoc);
//		}
	}
}
